package cn.vivi.service.impl;

import java.sql.SQLException;
import java.util.Collections;
import java.util.List;

import cn.vivi.domain.Classes;
import cn.vivi.mapper.ClassesMapper;
import cn.vivi.service.ClassesService;

public class ClassesServiceImpl implements ClassesService{

	private ClassesMapper classesMapper = new ClassesMapper();
	
	@Override
	public List<Classes> findAll() {
		try {
			return classesMapper.findAll();
		} catch (SQLException e) {
			e.printStackTrace();
			return Collections.emptyList();
		}
	}
	
	@Override
	public boolean addClasses(Classes classes) {
		try {
			return classesMapper.insert(classes);
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		}
	}
	
	@Override
	public boolean deleteClasses(String id) {
		try {
			return classesMapper.delete(id);
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		}
	}
	
	@Override
	public boolean updateClasses(Classes classes) {
		try {
			return classesMapper.update(classes);
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		}
	}
}
